
import abc

class BaseFileUtil(object):
    __metaclass__ = abc.ABCMeta

    @abc.abstractmethod
    def loader(self, file_path):
        pass
    
class TxtFileUtil(BaseFileUtil):
    def loader(self, file_path):
        with open(file_path, 'r', encoding='utf-8') as f:
            return f.read()
        
class DocxFileUtil(BaseFileUtil):
    
    def loader(self, file_path):
        return "docx"
    
class PdfFileUtil(BaseFileUtil):
    
    def loader(self, file_path):
        return "pdf"

class FileFactory:
    
    def get_sclass(self,type):
        if type == "txt":
            return TxtFileUtil()
        elif type == "docx":
            return DocxFileUtil()
        elif type == "pdf":
            return PdfFileUtil()
        else:
            return None

fileFactory = FileFactory()
file = fileFactory.get_sclass("docx")
print(file.loader("./test.docx"))